package com.atguigu.containers;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;

/**
 * ClassName: SetAndMap
 * Package: com.atguigu.containers
 * Description:
 *
 * @author: fu-wang
 * @create: 2024/10/29 19:44
 * version: 1.0
 */
public class SetAndMap {
    public static void main(String[] args) {
        Set<String> set = new CopyOnWriteArraySet<>();

        for (int i = 0; i < 100; i++) {
            new Thread(() -> {
                set.add(UUID.randomUUID().toString().substring(0, 8));
                System.out.println(set);
            }, String.valueOf(i)).start();
        }
    }

//    public static void main(String[] args) {
//        Map<String, String> map = new ConcurrentHashMap<>();
//
//        for (int i = 0; i < 100; i++) {
//            new Thread(() -> {
//                map.put(String.valueOf(Thread.currentThread().getName()), UUID.randomUUID().toString().substring(0, 8));
//                System.out.println(map);
//            }, String.valueOf(i)).start();
//        }
//    }

}
